package game.model.texture
{
	import game.model.texture.vo.TextureVO;
	import org.puremvc.as3.interfaces.IProxy;
	import org.puremvc.as3.patterns.proxy.Proxy;

	/**
	 * ...
	 * @author Thot
	 */
	
	public class TextureProxy extends Proxy implements IProxy
	{
		
		static public var NAME:String = 'TextureProxy';
		private var _data:Vector.<TextureVO>;
		
		public function TextureProxy()
		{ 
			_data = new Vector.<TextureVO>()
			super( NAME, _data );
		}
		
		
		public function addTexture( p_texture:TextureVO ):void
		{
			_data.push( p_texture );
		}
		
		public function removeTexture( p_texture:TextureVO ):void
		{
			var index:int = _data.indexOf( p_texture );
			if ( index != -1 )
			{
				_data.splice( index, 1 );
			}
		}
		
		public function getTextureById( p_id:int ):TextureVO
		{
			var i:int = _data.length;
			while ( --i > -1 )
			{
				if ( _data[i].id == p_id )
					return _data[i];
			}
			
			return null;
		}
		
		public function getTextureByName( p_name:String ):TextureVO
		{
			var i:int = _data.length;
			while ( --i > -1 )
			{
				if ( _data[i].name == p_name )
					return _data[i];
			}
			
			return null;
		}
		
		
		
	}

}